import { State } from "framework/FSM/AState";
import { BinaryDecision } from "framework/FSM/DecisionTree/Decision";
import { TargetState } from "framework/FSM/DecisionTree/DecisionTargetState";
import { DecisionTreeNode } from "framework/FSM/DecisionTree/DecisionTreeNode";
import { HierarchicalStateMachine } from "framework/FSM/HierarchicalStateMachine";
import { DecisionTreeTransition } from "framework/FSM/Transition/DecisionTreeTransition";
import { SleepState } from "../Control/State/normal/SleepState";

 

export class HFSMFactoryHelper
{
    

     public static CreateHFSMModuleBy<T extends BinaryDecision>(S:{new (trueNode?:DecisionTreeNode,falseNode?:DecisionTreeNode): T},state_module:State)
     {

         const sleepstate = new SleepState();

         const HSM = new HierarchicalStateMachine([state_module,sleepstate]);

         const decision_   = new S(new TargetState(state_module));
         const decision_sleep   = new S(undefined,new TargetState(sleepstate));
         state_module.addTransition(new DecisionTreeTransition(decision_sleep));
         sleepstate.addTransition(new DecisionTreeTransition(decision_));

         return HSM;
     }
}
